<%--
  Created by IntelliJ IDEA.
  User: MI
  Date: 2021/10/15
  Time: 9:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script>
        var xh;
        function ajax() {
            xh = new XMLHttpRequest();//异步对象
            xh.onreadystatechange = callback;
            // xh.open("GET","hello.do?a=1");//打开链接
            xh.open("POST","hello.do");//打开链接
            xh.send("name=zhao");//发送请求
        }
        function callback() {
            //alert("hello");
            if(xh.readyState == 4 && xh.status == 200){
                //alert("hello");
                //alert(responseText);
                document.getElementById("html").innerHTML = xh.responseText;
            }
        }
    </script>
</head>
<body>
    <button onclick="ajax()">试一试</button>
    <div id="html"></div>
</body>
</html>
